package com.example.p2pinvest.adapter;

import android.view.View;
import butterknife.ButterKnife;

/**
 * @author h2tc01
 * @version 1.0.0
 * 2022/8/10
 */
public abstract class BaseHolder<T>{
    //视图
    private View rootView;
    //数据
    private T data;

    public BaseHolder() {
        //初始化视图
        rootView = initView();
        //设置与此视图关联的标记
        rootView.setTag(this);

        ButterKnife.bind(this, rootView);
    }

    /**
     * 初始化视图
     * @return 视图
     */
    protected abstract View initView();

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
        refreshData();
    }

    /**
     * 具体装配过程,将数据展示到视图上
     */
    protected abstract void refreshData();

    public View getRootView() {
        return rootView;
    }
}
